FROM infiniflow/ragflow-base:v2.0
USER  root

WORKDIR /ragflow

# 使用国内镜像源
RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|https://mirrors.aliyun.com/ubuntu/|g' /etc/apt/sources.list && \
    apt-get update && \
    apt-get install -y --no-install-recommends \
    unoconv \
    libreoffice-core \
    libreoffice-writer \
    libreoffice-calc \
    libreoffice-impress \
    python3-uno \
    && rm -rf /var/lib/apt/lists/*

# 安装前端依赖，使用国内npm源
ADD ./web ./web
RUN cd ./web && npm config set registry https://registry.npmmirror.com && npm i --force && npm run build

# 添加其他项目文件
ADD ./api ./api
ADD ./conf ./conf
ADD ./deepdoc ./deepdoc
ADD ./rag ./rag
ADD ./agent ./agent
ADD ./graphrag ./graphrag

# 设置环境变量
ENV PYTHONPATH=/ragflow/
ENV HF_ENDPOINT=https://hf-mirror.com

# 添加入口脚本并赋予执行权限
ADD docker/entrypoint.sh ./entrypoint.sh
ADD docker/.env ./
RUN chmod +x ./entrypoint.sh

# 设置入口
ENTRYPOINT ["./entrypoint.sh"]